import {
  edit_input,
  edit_select_field,
  edit_select_kind,
} from '@/components/tables/cfg/table-render.jsx';

export const useTableColumns = () => {
  return {
    getColumns: ({ fieldOptions }) => {
      return [
        {
          field: 'field',
          title: '参数字段',
          width: 200,
          align: 'left',
          sortable: false,
          slots: {
            default: params => {
              // if (fieldOptions && fieldOptions.length) {
              //   return edit_select_field(params, fieldOptions);
              // } else {
              //   return edit_input(params);
              // }
              // const { row, column } = params
              // const findItem = fieldOptions.find(item => row[column.field] === item.field)
              // if (!findItem) {
              //   return edit_input(params);
              // } else {
              //   return row[column.field]
              // }
              return edit_input(params);
            },
          },
        },
        // {
        //   field: 'title',
        //   title: '参数名称',
        //   width: 200,
        //   align: 'left',
        //   sortable: false,
        //   slots: { default: params => edit_input(params, false) },
        // },
        {
          field: 'kind',
          title: '参数类型',
          width: 150,
          align: 'center',
          sortable: false,
          slots: { default: params => edit_select_kind(params, 'param') },
        },
        {
          field: 'defaultValue',
          title: '默认值',
          width: 200,
          align: 'center',
          sortable: false,
          slots: { default: params => edit_input(params, false) },
        },
        {
          field: 'paramRender',
          title: '参数配置',
          width: 80,
          align: 'center',
          sortable: false,
          slots: { default: 'param_render' },
        },
      ];
    },
  };
};

